/*
 * Copyright (c) 2011 Team A CS2340. All rights reserved.
 */
package edu.gatech.teama.doctorsoffice.net;

import edu.gatech.teama.doctorsoffice.server.DataModel;


/**
 * Describe the log in message by extending message class
 * 
 * @author Dylan
 * @version 1.0
 */
public class LoginMessage extends Message {

	/**
	 * the username of the login input
	 */
	private final String username; 
	
	/**
	 * the passwordhash of the the login input password
	 */
	private final String passwordHash;
	
	/**
	 * initialize instance payload
	 * @param username 
	 * @param passwordHash
	 */	
	public LoginMessage(String username, String passwordHash) {
		super(username);
		this.username = username;
		this.passwordHash = passwordHash;
	}
	
	/**
	 * send message for log in checking
	 * @param model data to manipulate in this case User
	 * @return message created
	 */
	public Message handle(final DataModel model) {
		// TODO Auto-generated method stub
		final LoginResult validPassword = 
			model.verifyPasswordHash(username, passwordHash);
		return new LoginResultMessage(validPassword);
	}

	public String toString() { // $codepro.audit.disable methodJavadoc
		return this.getPayload().toString();
	}
	
}
